//
//  AttackCell.m
//  mendianjieke
//
//  Created by 响当当 on 7/31/19.
//  Copyright © 2019 dongzheng. All rights reserved.
//

#import "AttackCell.h"

@interface AttackCell()
@property (nonatomic, strong)UIImageView *iconImageView;
@property (nonatomic, strong)UILabel *titleLabel;//标题
@property (nonatomic, strong)UILabel *subTitleLabel;//副标题
@end

@implementation AttackCell

- (UILabel *)titleLabel
{
    if (!_titleLabel)
    {
        _titleLabel = [Utilties creatLabelWithFrame:CGRectMake(15*kUIScaleBasePlus, 15*kUIScaleBasePlus,SCREEN_WIDTH,20*kUIScaleBasePlus)
                                       textAligment:NSTextAlignmentLeft
                                           textClor:LCHexColor(0x282828)
                                           textFont:14*kUIScaleBasePlus];
    }
    return _titleLabel;
}

- (UIImageView *)iconImageView
{
    if (!_iconImageView)
    {
        _iconImageView = [[UIImageView alloc]initWithFrame:CGRectMake(15*kUIScaleBasePlus,CGRectGetMaxY(self.titleLabel.frame)+7*kUIScaleBasePlus,15*kUIScaleBasePlus,15*kUIScaleBasePlus)];
        _iconImageView.image = [UIImage imageNamed:@"xing"];
    }
    return _iconImageView;
}

- (UILabel *)subTitleLabel
{
    if (!_subTitleLabel)
    {
        _subTitleLabel = [Utilties creatLabelWithFrame:CGRectMake(CGRectGetMaxX(self.iconImageView.frame)+2*kUIScaleBasePlus, CGRectGetMaxY(self.titleLabel.frame)+5*kUIScaleBasePlus,300*kUIScaleBasePlus,20*kUIScaleBasePlus)
                                       textAligment:NSTextAlignmentLeft
                                           textClor:LCHexColor(0xF5B200)
                                           textFont:13*kUIScaleBasePlus];
    }
    return _subTitleLabel;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        [self.contentView addSubview:self.iconImageView];
        [self.contentView addSubview:self.titleLabel];
        [self.contentView addSubview:self.subTitleLabel];
        
        UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(0,74*kUIScaleBasePlus,SCREEN_WIDTH,1*kUIScaleBasePlus)];
        lineView.backgroundColor = JSALineColor;
        [self.contentView addSubview:lineView];
    }
    return self;
}

- (void)setModel:(AttackModel *)model
{
    _model = model;
    self.titleLabel.text = model.title;
    if ([model.subtitle isEqualToString:@""])
    {
        self.iconImageView.hidden = YES;
    }
    else
    {
        self.subTitleLabel.text = model.subtitle;
        self.iconImageView.hidden = NO;
    }
}
@end
